package com.xiashitech.apiservice.api;


import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.xiashitech.apiservice.Constants.ErrorCode;
import com.xiashitech.apiservice.config.AgentConfig;
import com.xiashitech.apiservice.config.AuthConfig;
import com.xiashitech.apiservice.config.RabbitMqConfig;
import com.xiashitech.apiservice.dao.model.AgentNode;
import com.xiashitech.apiservice.dao.model.PushHistory;
import com.xiashitech.apiservice.dto.AgentIdentityDTO;
import com.xiashitech.apiservice.grpc.IncrementalCacheService;
import com.xiashitech.apiservice.service.IAgentNodeService;
import com.xiashitech.apiservice.service.IPushHistroyService;
import com.xiashitech.apiservice.service.IPushService;
import com.xiashitech.interfaces.apiservice.dto.base.Response;
import com.xiashitech.interfaces.apiservice.dto.system.SystemInfoResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Recover;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

@Controller
@RequiredArgsConstructor(onConstructor = @_(@Autowired))
@RequestMapping(value = "/v1/agent/push")
public class PushController {
    private final IPushService pushService;
    private final AuthConfig authConfig;
    private final IPushHistroyService pushHistroyService;
    private final IAgentNodeService agentNodeService;
    @Autowired
    private RabbitTemplate rabbitTemplate;
    private final IncrementalCacheService incrementalCacheService;
    private static final Log log = LogFactory.get();

    @RequestMapping(value = "/permissionInit", method = RequestMethod.POST)
    @ResponseBody
    @Retryable(value = Exception.class, maxAttempts = 3, backoff = @Backoff(delay = 600000, multiplier = 1.5))
    public JSONObject permissionInit(@RequestBody PushHistory pushHistory) throws Exception {
        JSONObject returnObj = new JSONObject();
        //try {
        new Thread(() -> {
            String systemId = pushHistory.getSystemId();
            AgentNode agentNode = new AgentNode();
            agentNode.setSystemId(systemId);
            JSONObject damObj = pushService.getDamInitContent(pushHistory, true);
            JSONObject desensitizationObj = pushService.getDesensitizationInitContent(pushHistory);
            agentNode.setServiceId(pushHistory.getServiceId());
            agentNode.setSerialId(pushHistory.getSerialId());
            agentNodeService.insertAgentNode(agentNode);
            List<AgentNode> pushAgentNodeList = new ArrayList<>();
            pushAgentNodeList.add(agentNode);
            pushService.pushToNode(systemId, pushAgentNodeList, desensitizationObj);
            //  incrementalCacheService.pushIncrementToClient(systemId, pushHistory.getServiceId(), pushHistory.getSerialId(), JSONUtil.toJsonStr(desensitizationObj));

            //incrementalCacheService.pushIncrementToClient(systemId, pushHistory.getServiceId(), pushHistory.getSerialId(), JSONUtil.toJsonStr(damObj));
            //log.info("damPushInit " + JSONUtil.toJsonStr(damObj));
            // log.info("desensitizationPushInit " + JSONUtil.toJsonStr(desensitizationObj));

            returnObj.putOpt("code", ErrorCode.RESULT_1001);
            returnObj.putOpt("damPushId", damObj.get("pushId"));
            returnObj.putOpt("desensitizationPushId", desensitizationObj.get("pushId"));
        }).start();


       /* } catch (Exception e) {
            e.printStackTrace();
        }*/
        return returnObj;
    }

    @Recover
    public JSONObject recover(Exception e, PushHistory pushHistory) {
        String systemId = pushHistory.getSystemId();
        System.out.println("回调方法执行！！！！" + systemId);
        PushHistory damPushHistory = new PushHistory();
        JSONObject damObj = pushService.getDamInitContent(pushHistory, true);
        PushHistory desensitizationPushHistory = new PushHistory();
        desensitizationPushHistory.setSystemId(systemId);
        desensitizationPushHistory.setServiceId(pushHistory.getServiceId());
        desensitizationPushHistory.setSerialId(pushHistory.getSerialId());
        desensitizationPushHistory.setContent(JSONUtil.toJsonStr(pushService.getDesensitizationInitContent(pushHistory)));
        desensitizationPushHistory.setStatus(0);
        pushHistroyService.insertPushHistroy(desensitizationPushHistory);
        JSONObject returnObj = new JSONObject();
        returnObj.putOpt("code", ErrorCode.RESULT_4001);
        returnObj.putOpt("damPushId", damObj.get("pushId"));
        returnObj.putOpt("desensitizationPushId", pushService.getDesensitizationInitContent(pushHistory).get("pushId"));
        return returnObj;

        //记日志到数据库 或者调用其余的方法

    }

    @RequestMapping(value = "/rabbittest", method = RequestMethod.GET)
    @ResponseBody
    public SystemInfoResponse RabbitTest(HttpServletRequest request) {
        //helloSender.send();
        String a = request.getParameter("a") == null ? "" : request.getParameter("a");

        //  String testDamContent ="{\"pushKey\": \"permissionChange\", \"systemId\": \"jsh-erp\", \"old\": [\"48.346.jsh-erp.default.jsh_erp.jsh_log.id.select.-1\", \"48.346.jsh-erp.default.jsh_erp.jsh_log.create_time.select.1\", \"48.346.jsh-erp.default.jsh_erp.jsh_account_item.bill_id.select.1\", \"48.346.jsh-\"]\n" +
        //       ",\n" +
        //   " \"new\": [\"48.346.jsh-erp.default.jsh_erp.jsh_log.id.select.1\", \"48.346.jsh-erp.default.jsh_erp.jsh_log.create_time.select.1\", \"48.346.jsh-erp.default.jsh_erp.jsh_account_item.bill_id.select.1\", \"48.346.jsh-\"]\n" +
        //    "\n" +
        //   "}";
        String testDamContent = "{\"pushKey\": \"permissionChange\", \"systemId\": \"jsh-erp\", \"old\": [\"118.14597.租户.346.jsh-erp.default.jsh_erp.jsh_log.id.select.-1\", \"118.14597.租户.346.jsh-erp.default.jsh_erp.jsh_log.create_time.select.1\", \"118.14597.租户.346.jsh-erp.default.jsh_erp.jsh_account_item.bill_id.select.1\", \"118.14597.租户.346.jsh-\"]\n" +
                ",\n" +
                " \"new\": [\"118.14597.租户.346.jsh-erp.default.jsh_erp.jsh_log.id.select.1\", \"118.14597.租户.346.jsh-erp.default.jsh_erp.jsh_log.create_time.select.1\", \"118.14597.租户.348.jsh-erp.default.jsh_erp.jsh_account_item.bill_id.select.1\", \"118.14597.租户.346.jsh-\"]\n" +
                "\n" +
                "}";
        String context = "";
        String content = "{\n" +
                "    \"pushKey\":\"permissionChange\",\n" +
                "    \"systemId\":\"jsh-erp\",\n" +
                "    \"old\":[\n" +
                "        \"48.jshERP.default.jsh_erp.jsh_account.null.select.0\",\n" +
                "        \"48.jshERP.default.jsh_erp.jsh_account.name.select.1\"\n" +
                "    ],\n" +
                "    \"new\":[\n" +
                "        \"48.jshERP.default.jsh_erp.jsh_account.null.select.1\",\n" +
                "        \"48.jshERP.default.jsh_erp.jsh_account.name.select.1\",\n" +
                "        \"48.jshERP.default.jsh_erp.jsh_account.code.select.1\"\n" +
                "    ]\n" +
                "}";
        String groupUserChangeContent = " {\"pushKey\": \"groupUserChange\", \"systemId\": \"jsh-erp\", \"change\": {\n" +
                "\"groupIdList\":[346,350]}}";

        String authContent = "{\"pushKey\":\"desensitizationChange\",\"systemId\":\"jsh-erp\",\"change\":[{\"table\":\"jsh-erp-test1.default.jsh_erp.jsh_account\",\"desensitization\":{\"authDesenseSet\":[{\"entityFQN\":\"jsh-erp.default.jsh_erp.jsh_account.name\",\"authDesense\":[{\"apiFQN\":\"ApiServiceTest.jsh-erp-6._account_getAccount\",\"apiPath\":\"/account/getAccount\",\"systemFQN\":\"ApiServiceTest.jsh-erp-6\",\"systemName\":\"jsh-erp-6\",\"patchPath\":\"/data/accountList/*/name\",\"regularCode\":\"111\",\"regular\":\"(.{1}).*\",\"replaceSymbol\":\"$1***\",\"isExecute\":true},{\"apiFQN\":\"ApiService.jsh-erp-6._testGetUserToken\",\"apiPath\":\"/testGetUserToken\",\"systemFQN\":\"ApiService.jsh-erp-6\",\"systemName\":\"jsh-erp-6\",\"patchPath\":\"/username\",\"regularCode\":\"111\",\"regular\":\"(.{1}).*\",\"replaceSymbol\":\"$1***\",\"isExecute\":true},{\"apiFQN\":\"ApiService.jsh-erp-6._testAxis22\",\"apiPath\":\"/testAxis22\",\"systemFQN\":\"ApiService.jsh-erp-6\",\"systemName\":\"jsh-erp-6\",\"patchPath\":\"/username\",\"regularCode\":\"111\",\"regular\":\"(.{1}).*\",\"replaceSymbol\":\"$1***\",\"isExecute\":true},{\"apiFQN\":\"ApiService.jsh-erp-6._testApacheHttp45\",\"apiPath\":\"/testApacheHttp45\",\"systemFQN\":\"ApiService.jsh-erp-6\",\"systemName\":\"jsh-erp-6\",\"patchPath\":\"/username\",\"regularCode\":\"111\",\"regular\":\"(.{1}).*\",\"replaceSymbol\":\"$1***\",\"isExecute\":true},{\"apiFQN\":\"ApiService.jsh-erp-6._userAuthInfo\",\"apiPath\":\"/userAuthInfo\",\"systemFQN\":\"ApiService.jsh-erp-6\",\"systemName\":\"jsh-erp-6\",\"patchPath\":\"/username\",\"regularCode\":\"111\",\"regular\":\"(.{1}).*\",\"replaceSymbol\":\"$1***\",\"isExecute\":true}]}]}}]}";
        String authContent2 = "{\"systemId\":\"haier-test\",\"change\":[{\"table\":\"haier-test.default.haier_test.sync_task_detail\",\"desensitization\":{\"authDesenseSet\":[{\"entityFQN\":\"haier-test.default.haier_test.sync_task_detail.creator\",\"authDesense\":[{\"apiFQN\":\"/cdp/getTags\",\"apiPath\":\"/cdp/getTags\",\"systemFQN\":\"haier-test\",\"systemName\":\"haier-test\",\"patchPath\":\"/*\",\"regularId\":\"8\",\"regular\":\".+\",\"replaceSymbol\":\"*\",\"isExecute\":true,\"regularName\":\"通用-全部脱敏为*\"}]}]}}],\"pushKey\":\"desensitizationChange\",\"pushId\":1237}\n" +
                "30 DesenseDebug, AuthService onMessage json: {\"systemId\":\"haier-test\",\"change\":[{\"table\":\"haier-test.default.haier_test.sync_task_detail\",\"desensitization\":{\"authDesenseSet\":[{\"entityFQN\":\"haier-test.default.haier_test.sync_task_detail.creator\",\"authDesense\":[{\"apiFQN\":\"/cdp/getTags\",\"apiPath\":\"/cdp/getTags\",\"systemFQN\":\"haier-test\",\"systemName\":\"haier-test\",\"patchPath\":\"/*\",\"regularId\":\"8\",\"regular\":\".+\",\"replaceSymbol\":\"*\",\"isExecute\":true,\"regularName\":\"通用-全部脱敏为*\"}]}]}}],\"pushKey\":\"desensitizationChange\",\"pushId\":1237}";
        String perMissionChangePaasContent = "{\n" +
                "    \"pushKey\":\"permissionChange\",\n" +
                "    \"systemId\":\"jsh-erp\",\n" +
                "    \"old\":[\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.id.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.number.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.name.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.parent_number.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.url.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.component.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.state.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.sort.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.enabled.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.type.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.push_btn.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.icon.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.delete_flag.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.description.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.id.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.bank_name.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.isystem.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.delete_flag.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.telephone.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.account_number.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.all_need_get.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.tenant_id.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.contacts.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.supplier.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.enabled.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.begin_need_get.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.tax_num.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.type.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.begin_need_pay.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.email.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.advance_in.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.tax_rate.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.all_need_pay.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.fax.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.address.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.phone_num.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.fax.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.supplier.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.bank_name.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.enabled.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.contacts.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.begin_need_pay.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.email.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.tenant_id.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.delete_flag.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.advance_in.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.tax_rate.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.description.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.type.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.address.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.begin_need_get.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.id.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.phone_num.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.isystem.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.account_number.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.all_need_pay.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.telephone.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.tax_num.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.all_need_get.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.status.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.user_id.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.id.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.client_ip.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.content.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.tenant_id.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.operation.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.create_time.select.-1\"\n" +
                "    ],\n" +
                "    \"new\":[\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.status.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.user_id.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.id.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.client_ip.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.content.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.tenant_id.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.operation.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_log.create_time.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.id.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.number.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.name.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.parent_number.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.url.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.component.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.state.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.sort.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.enabled.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.type.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.push_btn.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.icon.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_function.delete_flag.select.1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.description.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.id.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.bank_name.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.isystem.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.delete_flag.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.telephone.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.account_number.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.all_need_get.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.tenant_id.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.contacts.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.supplier.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.enabled.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.begin_need_get.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.tax_num.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.type.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.begin_need_pay.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.email.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.advance_in.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.tax_rate.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.all_need_pay.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.fax.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.address.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.phone_num.select.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.fax.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.supplier.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.bank_name.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.enabled.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.contacts.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.begin_need_pay.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.email.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.tenant_id.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.delete_flag.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.advance_in.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.tax_rate.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.description.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.type.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.address.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.begin_need_get.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.id.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.phone_num.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.isystem.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.account_number.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.all_need_pay.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.telephone.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.tax_num.update.-1\",\n" +
                "        \"118.14597.\\u79df\\u6237.351.jsh-erp.default.jsh_erp.jsh_supplier.all_need_get.update.-1\"\n" +
                "    ]\n" +
                "}";
        String paasDelUserContent = "{\"pushKey\": \"groupUserChange\", \"systemId\": \"jsh-erp\", \"change\": {\"groupIdList\": [352]}}";
        if (a.equals("1")) {
            context = "Hi, I am message one";
            System.out.println("Sender : " + context);
            DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_NAME, RabbitMqConfig.DAM_ROUTING_KEY, testDamContent);
        } else if (a.equals("2")) {
            context = "Hi, I am message two";
            System.out.println("Sender : " + context);
            DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_NAME, RabbitMqConfig.DESENSITIZATION_ROUTING_KEY, authContent2);
        } else if (a.equals("3")) {
            context = "Hi, I am message three";
            System.out.println("Sender : " + context);
            DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_NAME, RabbitMqConfig.DAM_ROUTING_KEY, groupUserChangeContent);
        } else if (a.equals("5")) {
            context = "Hi, I am message five";
            System.out.println("Sender : " + context);
            DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_NAME, RabbitMqConfig.DAM_ROUTING_KEY, perMissionChangePaasContent);
        }
        else if("6".equals(a))
        {
            String newGroupChangeContent = "{\"pushKey\": \"groupUserChange\", \"systemId\": \"jsh-erp\", \"change\":\n" +
                    " {\n" +
                    "\"userChange\":{\n" +
                    "\"groupId\":\"350\",\n" +
                    "\"userId\":\"1\",\n" +
                    "\"action\":\"add\"\n" +
                    "}\n" +
                    "}\n" +
                    "}";
            context = "Hi, I am message three";
            System.out.println("Sender : " + context);
            DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_NAME, RabbitMqConfig.DAM_ROUTING_KEY, newGroupChangeContent);
        }
        else {
            context = "boot hello " + new Date();
            System.out.println("Sender : " + context);
            //rabbitTemplate.convertAndSend(RabbitConfig.EXCHANGE_NAME,"boot.haha", "boot mq hello~~~");
        }
        //new RabbitMqUtil().send("hello");
        return SystemInfoResponse.builder().code("1").message(context).build();
    }

}

